package com.jiankang.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.jiankang.entity.HealthFile;
import com.jiankang.entity.User;
import com.jiankang.service.HealthFileService;
import com.jiankang.service.UserService;
import com.jiankang.util.Page;

@Controller
@RequestMapping("/filesave")
public class HealthFileController {
	@Resource
	private HealthFileService HealthFileService;
	@Resource
	private UserService  userService ;
	@RequestMapping(value ="/searchFile",method = RequestMethod.GET)
	public String  searchFile(Model model, HttpServletRequest req) throws  Exception
	{
		List<User> user=userService.getAllUser();
		String pageNow = req.getParameter("pageNow");
		Page page = null;
		List<HealthFile> healthfile=null;
		int totalCount = (int) HealthFileService.getAllProductCount();
		if (pageNow != null) {
			page = new Page(totalCount, Integer.parseInt(pageNow));
			healthfile=HealthFileService.getHealthFile(page);
		}else{
			page = new Page(totalCount, 1);
			healthfile=HealthFileService.getHealthFile(page);
		}
		model.addAttribute("page", page);
		model.addAttribute("healthfile", healthfile);
		model.addAttribute("user", user);
		return "admin/healthfile";
	}
}
